package com.hc.demo.service;

import com.hc.demo.domain.Cidetailedreport;
import com.hc.demo.domain.Cireport;
import com.hc.demo.dto.ResultResponse;
import com.hc.demo.mapper.CidetailedreportMapper;
import com.hc.demo.mapper.CireportMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class ReportServiceImpl  implements  ReportService{
    @Autowired
    CidetailedreportMapper cidetailedreportMapper;
    @Autowired
    CireportMapper cireportMapper;


    public ResultResponse getReportAndReportdetailedByOrderId(Integer orderId){
        List<Cireport> cireports=cireportMapper.selecctByOrderId(orderId);

        for(Cireport cr:cireports){
            Integer ciId=cr.getCiId();

            List<Cidetailedreport> cidetailedreports=cidetailedreportMapper.selectByCheckitemIdAndOrderId(ciId,orderId);

            cr.setCidetailedreportList(cidetailedreports);
        }

        return new ResultResponse(ResultResponse.SUCCESS_CODE,ResultResponse.SUCCESS_DESC,cireports);

    }
}
